// 访问 token 缓存的 key
const ACCESS_TOKEN_KEY = 'access_token'
// 刷新 token 缓存的 key
const REFRESH_TOKEN_KEY = 'refresh_token'

function getToken(): string {
  return uni.getStorageSync(ACCESS_TOKEN_KEY) || ''
}

function setToken(token: string) {
  console.log('setToken', token)
  uni.setStorageSync(ACCESS_TOKEN_KEY, token)
}

function getRefreshToken(): string {
  return uni.getStorageSync(REFRESH_TOKEN_KEY) || ''
}

function setRefreshToken(token: string) {
  uni.setStorageSync(REFRESH_TOKEN_KEY, token)
}

function clearToken() {
  uni.removeStorageSync(ACCESS_TOKEN_KEY)
  uni.removeStorageSync(REFRESH_TOKEN_KEY)
}

export { getToken, setToken, clearToken, getRefreshToken, setRefreshToken }
